<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../include/head.jspf"%>      
<style>
body { background: #f5f5f5 ;}
</style>

<!--[if lt IE 7.]>
<script defer type="text/javascript" src="js/pngfix.js"></script>
<![endif]-->
<script>
$(document).ready(function(){
	if(getCookie('remember') == 'true'){
		$("#loginId").val(getCookie('username'));
		$("#password").val(getCookie('password'));
		$("#remember").attr("checked",true);
	}
		
})

function dologin(){
	var errorMsg = "";
	errorMsg += sl_check($("#loginId")[0], "用户名", 30, 1);
	errorMsg += sl_check($("#password")[0], "密码", 20, 1);
	
	if($("#remember").is(":checked")){
		setCookie($("#loginId").val(),$("#password").val());
	}else{
		cleanCookie();
	}
	
	if(errorMsg != ""){
		alert(errorMsg);
		return false;
	}else{
		$("#loginForm").submit();
	}
}

function getCookie(c_name)      
{
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=")
        if (c_start != -1) { 
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf("^",c_start);
            if (c_end==-1)
                c_end=document.cookie.length;
            return document.cookie.substring(c_start,c_end);
    } 
  }
    return "";
}

function setCookie(username, password)       
{
	var exdate = new Date();
    exdate.setDate(exdate.getDate() + 365);
    document.cookie = "username=" + escape(username) + "^password=" + escape(password) + "^remember=true^;expires=" + exdate.toGMTString();
}


function cleanCookie () {    
    document.cookie = "username=" + ";" + "password=" + ";expires=Thu, 01-Jan-70 00:00:01 GMT";
}
	
</script>
</head>
  
	<body id="login">
		
		<div id="login-wrapper" class="png_bg">
		  <div id="login-top">
			
				<h1>东方易云</h1>
				<!-- Logo (221px width) -->
				<img id="logo" src="resource/images/logo.png" alt="数据交换平台" />
			</div> <!-- End #logn-top -->
			
			<div id="login-content">
				
				<form action="login" method="post" id="loginForm" onsubmit="dologin();return false;">
					<p>
						<label>用户名</label>
						<input class="text-input" type="text" name="loginId" id="loginId"/>
					</p>
					<div class="clear"></div>
					<p>
						<label>密&nbsp;&nbsp;码</label>
						<input class="text-input" type="password" name="password" id="password"/>
					</p>
					<div class="clear"></div>
					<p id="remember-password">
						<input type="checkbox" id="remember" />Remember me
					</p>
					<div class="clear"></div>
					<p>
						<input class="button" type="submit" value="登&nbsp;&nbsp;录" />
					</p>
					
				</form>
			</div> <!-- End #login-content -->
			
		</div> <!-- End #login-wrapper -->
		
  </body>
  </html>
